package cn.felord.rediscache;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/cache")
public class CacheApi {

    @Resource
    private CaptchaCache captchaCache;

    @GetMapping("/put")
    public String putCode() {
        String code = "12324";
        captchaCache.put("myKey", code);
        return code;
    }

    @GetMapping("/get")
    public String getCode() {
        return captchaCache.get("myKey");
    }

    @GetMapping("/exp")
    public void expire() {
        captchaCache.expire("myKey");
    }
}





